/* eslint-disable @typescript-eslint/no-empty-object-type */

// import axios from 'axios';
import { baseRequestClient, requestClient } from '#/api/request';

export namespace TeamApi {
  export interface TeamListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface TeammemberListParams {
    pageNum: number;
    pageSize: number;
    teamId: null | number;
  }
  export interface TeammemberByIdParams {
    ids: null | string;
  }
  export interface TeammemberParams {
    nickName: string;
    teamId: number;
    tel: string;
    userId: number;
    userName: string;
  }
  export interface Params {}
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null | string;
    remark: string;
    params: Params;
    teamId: number;
    teamCode: string;
    teamName: string;
    calendarType: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface Row1 {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    memberId: number;
    teamId: number;
    userId: number;
    userName: string;
    nickName: string;
    tel: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface TeamListResult {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
  export interface TeamListAllResult {
    data: Row[];
  }
  export interface TeammemberListResult {
    total: number;
    rows: Row1[];
    code: number;
    msg: string;
  }
  export interface TeammemberByIdResult {
    data: Row1[];
    code: number;
    msg: string;
  }
}

// 获取班组列表
export const getTeamList = (data: TeamApi.TeamListParams) => {
  return requestClient.get<TeamApi.TeamListResult>('/mes/cal/team/list', {
    params: data,
  });
};
// 获取班组列表
export const getTeamListAll = () => {
  return requestClient.get<TeamApi.TeamListAllResult>('/mes/cal/team/listAll');
};
// 获取班组成员列表
export const getTeammemberList = (data: TeamApi.TeammemberListParams) => {
  return requestClient.get<TeamApi.TeammemberListResult>(
    '/mes/cal/teammember/list',
    {
      params: data,
    },
  );
};
// 通过id获取班组成员列表
export const getTeammemberById = (data: TeamApi.TeammemberByIdParams) => {
  return requestClient.get<TeamApi.TeammemberByIdResult>(
    '/mes/cal/teammember/getListByTeamId',
    {
      params: data,
    },
  );
};

// 新增班组
export const addTeam = (data: TeamApi.Row) =>
  requestClient.post<TeamApi.TeamListResult>('/mes/cal/team', data);

// 新增班组成员
export const addTeammember = (data: TeamApi.TeammemberParams) =>
  requestClient.post<TeamApi.TeammemberListResult>('/mes/cal/teammember', data);

// 修改班组
export const updateTeam = (data: TeamApi.Row) =>
  requestClient.put<TeamApi.TeamListResult>('/mes/cal/team', data);

// 自动生成班组编号
export const getTeamCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/CAL_TEAM_CODE');
